<template><div><h2 id="贡献指南" tabindex="-1"><a class="header-anchor" href="#贡献指南"><span>贡献指南</span></a></h2>
<ul>
<li><a href="#bug-reports">Bug 报告</a></li>
<li><a href="#support-questions">帮助支持</a></li>
<li><a href="#core-development-discussion">核心发展讨论</a></li>
<li><a href="#which-branch">哪个分支？</a></li>
<li><a href="#compiled-assets">编译资源</a></li>
<li><a href="#security-vulnerabilities">安全漏洞</a></li>
<li><a href="#coding-style">代码风格</a>
<ul>
<li><a href="#phpdoc">PHPDoc</a></li>
<li><a href="#styleci">StyleCI</a></li>
</ul>
</li>
<li><a href="#code-of-conduct">行为准则</a></li>
</ul>
<h2 id="bug-报告" tabindex="-1"><a class="header-anchor" href="#bug-报告"><span>Bug 报告</span></a></h2>
<p>为了鼓励活跃的协作，Laravel 强烈推荐拉取请求，而不仅仅是错误报告。只有标记为「准备好审查」（而不是「草稿」状态）且新功能的所有测试都通过的拉取请求才会进行审核。留在「草稿」状态中未处理的悬而未决、不活跃的拉取请求将在几天后关闭。</p>
<p>不过，如果你提交了错误报告，你的问题应包含标题和清晰的问题描述。你还应尽可能提供相关信息和演示问题的代码示例。错误报告的目的是使自己和其他人能够轻松地复制错误并开发修复程序。</p>
<p>请记住，错误报告的创建是希望其他拥有相同问题的人能够与你协作解决问题。不要期望错误报告会自动获得任何活动，或者其他人会迅速修复它。创建错误报告有助于你自己和其他人开始解决问题的路径。如果你想参与，可以通过修复 <a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+label%3Abug+user%3Alaravel" target="_blank" rel="noopener noreferrer">我们的问题跟踪器中列出的任何错误</a> 来帮助。你必须使用 GitHub 进行身份验证才能查看 Laravel 的所有问题。</p>
<p>如果你在使用 Laravel 时注意到不正确的 DocBlock、PHPStan 或 IDE 警告，请不要创建 GitHub 问题。相反，请提交拉取请求以解决问题。</p>
<p>Laravel 的源代码托管在 GitHub 上，每个 Laravel 项目都有一个仓库：</p>
<h2 id="帮助支持" tabindex="-1"><a class="header-anchor" href="#帮助支持"><span>帮助支持</span></a></h2>
<p>Laravel 的 GitHub 问题跟踪器不适用于提供 Laravel 帮助或支持。请使用以下渠道之一：</p>
<h2 id="核心发展讨论" tabindex="-1"><a class="header-anchor" href="#核心发展讨论"><span>核心发展讨论</span></a></h2>
<p>可以在 Laravel 框架存储库的 <a href="https://github.com/laravel/framework/discussions" target="_blank" rel="noopener noreferrer">GitHub discussion board</a> 。中提出新功能或改进现有 Laravel 行为。如果提出了新功能，请愿意实现至少一些完成该功能所需的代码。</p>
<p>关于错误、新功能和现有功能的实现的非正式讨论在 <a href="https://discord.gg/laravel" target="_blank" rel="noopener noreferrer">Laravel Discord server</a> 的 #internals 频道进行。Laravel 的维护者 Taylor Otwell 通常在周一至周五上午8点至下午5点（UTC-06:00或美国/芝加哥）在频道中出现，并在其他时间不定期出现。</p>
<h2 id="哪个分支" tabindex="-1"><a class="header-anchor" href="#哪个分支"><span>哪个分支？</span></a></h2>
<p><strong>所有的</strong> Bug 修复应该发送到支持 Bug 修复的最新版本（目前是 <code v-pre>10.x</code>）。Bug 修复不应该发送到主分支，除非它们仅修复即将发布的版本中存在的功能。</p>
<p>完全向后兼容当前版本的小型功能可以发送到最新的稳定分支（目前是 <code v-pre>10.x</code>）。</p>
<p>具有重大新特性或破坏性更改的功能应该始终发送到主分支，该分支包含即将发布的版本。</p>
<h2 id="编译资源" tabindex="-1"><a class="header-anchor" href="#编译资源"><span>编译资源</span></a></h2>
<p>如果你正在提交将影响编译文件的更改，例如 laravel/laravel 存储库中的 resources/css 或 resources/js 中的大多数文件，请不要提交编译文件。由于它们的尺寸较大，维护者无法实际审核它们。这可以被利用作为将恶意代码注入 Laravel 的方法。为了防御性地防止这种情况，所有编译文件将由 Laravel 维护者生成和提交。</p>
<h2 id="安全漏洞" tabindex="-1"><a class="header-anchor" href="#安全漏洞"><span>安全漏洞</span></a></h2>
<p>如果你在 Laravel 中发现安全漏洞，请发送电子邮件至 Taylor Otwell <a href="mailto:taylor@laravel.com" target="_blank" rel="noopener noreferrer"></a><a href="mailto:taylor@laravel.com" target="_blank" rel="noopener noreferrer">taylor@laravel.com</a> 。所有安全漏洞将得到及时处理。</p>
<h2 id="代码风格" tabindex="-1"><a class="header-anchor" href="#代码风格"><span>代码风格</span></a></h2>
<p>Laravel 遵循 <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide." target="_blank" rel="noopener noreferrer">PSR-2</a> 编码标准和 <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader." target="_blank" rel="noopener noreferrer">PSR-4</a> 自动加载标准。</p>
<h3 id="phpdoc" tabindex="-1"><a class="header-anchor" href="#phpdoc"><span>PHPDoc</span></a></h3>
<p>是一种在 PHP 代码中使用文档块注释的方式，它可以让开发者快速了解代码中的类、方法、属性等信息。下面是一个有效的 Laravel 文档块注释的示例。注意，<code v-pre>@param</code> 属性后面跟着两个空格、参数类型、两个空格，最后是变量名：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line">* 容器注册与绑定</span>
<span class="line">*</span>
<span class="line">* <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span><span class="token punctuation">|</span><span class="token keyword">array</span></span>  <span class="token parameter">$abstract</span></span>
<span class="line">* <span class="token keyword">@param</span>  <span class="token class-name"><span class="token punctuation">\</span>Closure<span class="token punctuation">|</span><span class="token keyword">string</span><span class="token punctuation">|</span><span class="token keyword">null</span></span>  <span class="token parameter">$concrete</span></span>
<span class="line">* <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">bool</span></span>  <span class="token parameter">$shared</span></span>
<span class="line">* <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line">*</span>
<span class="line">* <span class="token keyword">@throws</span> <span class="token class-name"><span class="token punctuation">\</span>Exception</span></span>
<span class="line">*/</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">bind</span><span class="token punctuation">(</span><span class="token variable">$abstract</span><span class="token punctuation">,</span> <span class="token variable">$concrete</span> <span class="token operator">=</span> <span class="token constant">null</span><span class="token punctuation">,</span> <span class="token variable">$shared</span> <span class="token operator">=</span> <span class="token constant boolean">false</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// ...</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>如果使用了 PHP 本地类型，则可以删除 @param 或 @return 属性：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line">* 执行任务</span>
<span class="line">*/</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">handle</span><span class="token punctuation">(</span><span class="token class-name type-declaration">AudioProcessor</span> <span class="token variable">$processor</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword return-type">void</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">//...</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>当使用的本地类型是泛型时，请通过使用 @param 或 @return 属性指定泛型类型：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line">*  获取消息.</span>
<span class="line">*</span>
<span class="line">* <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">array</span></span>&lt;int, \Illuminate\Mail\Mailables\Attachment></span>
<span class="line">*/</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">attachments</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword return-type">array</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token class-name static-context">Attachment</span><span class="token operator">::</span><span class="token function">fromStorage</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'/path/to/file'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="styleci" tabindex="-1"><a class="header-anchor" href="#styleci"><span>StyleCI</span></a></h3>
<p>别担心你的代码风格, <a href="https://styleci.io/" target="_blank" rel="noopener noreferrer">StyleCI</a> 是一个自动化的代码风格工具，它会在拉取请求合并后自动合并代码格式修复。这样我们就可以将重点放在贡献内容上，而不是代码风格上。</p>
<h2 id="行为准则" tabindex="-1"><a class="header-anchor" href="#行为准则"><span>行为准则</span></a></h2>
<p>Laravel 的行为准则源自于 Ruby 的行为准则。如果违反了行为准则，可以向 Taylor Otwell（<a href="mailto:taylor@laravel.com" target="_blank" rel="noopener noreferrer">taylor@laravel.com</a>）报告：</p>
<ul>
<li>参与者应尊重不同的观点。</li>
<li>参与者必须确保他们的语言和行为没有人身攻击和贬低个人言论。</li>
<li>在解释他人的言行时，参与者应始终保持良好的意图。</li>
<li>不能容忍可合理视为骚扰的行为。</li>
</ul>
<blockquote>
<p>本译文仅用于学习和交流目的，转载请务必注明文章译者、出处、和本文链接<br>
我们的翻译工作遵照 <a href="https://learnku.com/docs/guide/cc4.0/6589" target="_blank" rel="noopener noreferrer">CC 协议</a>，如果我们的工作有侵犯到您的权益，请及时联系我们。</p>
</blockquote>
<hr>
<blockquote>
<p>原文地址：<a href="https://learnku.com/docs/laravel/10.x/contributions/14834" target="_blank" rel="noopener noreferrer">https://learnku.com/docs/laravel/10.x/co...</a></p>
<p>译文地址：<a href="https://learnku.com/docs/laravel/10.x/contributions/14834" target="_blank" rel="noopener noreferrer">https://learnku.com/docs/laravel/10.x/co...</a></p>
</blockquote>
</div></template>


